#include <iostream>
#include <string>


#include "txtview.h"
#include "../user/user.h"
#include "../ufile/ufile.h"

// void print_user(const & User utilisateur)
//{
//}


void TxtView::printTree(const FileTree& arbre)
{
    TxtView::printTreeBetween(arbre._localFiles(), arbre._localFiles().begin(), arbre._localFiles().end());
}

void TxtView::printTreeBetween(const file_tree& tr, file_tree::pre_order_iterator it, file_tree::pre_order_iterator end)
{
    cout << "printing tree" << endl;
    if (!tr.is_valid(it)) return;
    // cout << "iterator is valid" << endl;
    int rootdepth=tr.depth(it);
    std::cout << "-----" << std::endl;
    while (it!=end)
    {
        for (int i=0; i<tr.depth(it)-rootdepth; ++i)
            std::cout << "  ";
        std::cout << it->_name() << " - " << it->_owner()._nickname() << " - " << it->_type() << std::endl << std::flush;
        ++it;
    }
    std::cout << "-----" << std::endl;
}
